 {extend name="v1/layout/base"}
 {block name="content"}
 <style>
   .layui-btn-group {
     width: 250px;
     height: auto;
   }

   .layui-table-cell,
   .layui-table-tool-panel li {
     overflow: visible;
     white-space: pre-wrap;
   }

   .layui-table-cell {
     height: auto;
     line-height: 35px;
   }
 </style>
 <div class="layuimini-main">

   <fieldset class="table-search-fieldset xk-search-status" id="xk-search-status">
     <legend>搜索信息</legend>
     <div style="margin: 10px 10px 10px 10px">
       <div class="layui-row layui-col-space15">
         <div class="layui-col-md12">
           <form class="layui-form">
             <div class="layui-card-body layui-form layui-form-pane">
               <div class="layui-row layui-col-space10 layui-form-item">
                   <div class="layui-col-lg6">
                     <label class="layui-form-label">昵称/会员号/手机号</label>
                     <div class="layui-input-block">
                       <input type="text" name="keywords" placeholder="请输入会员昵称/会员号/手机号" id="keywords" class="layui-input">
                     </div>
                   </div>
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">会员等级</label>
                   <div class="layui-input-block">
                     {volist name="$user_level_list" id="vo"}
                     <input type="checkbox" class="layui-input" lay-skin="primary" name="level" value="{$vo.level}" title="{$vo.level_name}">
                     {/volist}
                   </div>
                 </div>
               </div>
               <div class="layui-row layui-col-space10 layui-form-item">
                   <div class="layui-col-lg6">
                     <label class="layui-form-label">上级会员号：</label>
                     <div class="layui-input-block">
                       <input type="text" placeholder="请输入上级会员号" id="search_user_sn" class="layui-input">
                     </div>
                   </div>
                   <div class="layui-col-lg6">
                     <label class="layui-form-label">是否有上级：</label>
                     <div class="layui-input-block">
                       <select name="has_l_user" id="has_l_user" lay-search>
                         <option value="">是否有上级</option>
                         <option value="1">有上级</option>
                         <option value="2">无上级</option>

                       </select>
                     </div>
                   </div>
               </div>
               <div class="layui-row layui-col-space10 layui-form-item">
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">消费金额</label>
                   <div class="layui-input-inline" style="width: 200px;">
                     <input type="text" name="min_team_achievement_price" id="min_purchases_order_price" placeholder="￥" autocomplete="off" class="layui-input">
                   </div>
                   <div class="layui-form-mid">-</div>
                   <div class="layui-input-inline" style="width: 200px;">
                     <input type="text" name="max_team_achievement_price" id="max_purchases_order_price" placeholder="￥" autocomplete="off" class="layui-input">
                   </div>
                 </div>
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">佣金金额</label>
                   <div class="layui-input-inline" style="width: 200px;">
                     <input type="text" name="min_team_achievement_price" id="min_back_money" placeholder="￥" autocomplete="off" class="layui-input">
                   </div>
                   <div class="layui-form-mid">-</div>
                   <div class="layui-input-inline" style="width: 200px;">
                     <input type="text" name="max_team_achievement_price" id="max_back_money" placeholder="￥" autocomplete="off" class="layui-input">
                   </div>
                 </div>
               </div>
               <div class="layui-row layui-col-space10 layui-form-item">
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">会员标签</label>
                   <div class="layui-input-block">
                     {volist name="$user_label_list" id="vo"}
                     <input type="checkbox" class="layui-input" lay-skin="primary" name="user_label_id" value="{$vo.user_label_id}" title="{$vo.user_label_name}">
                     {/volist}
                   </div>
                 </div>
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">绑定时间</label>
                   <div class="layui-input-block">
                     <input type="text" class="layui-input" autocomplete="off" id="bind_time" placeholder="请选择对应的绑定时间区间">
                   </div>
                 </div>
               </div>
               <div class="layui-row layui-col-space10 layui-form-item">
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">注册时间</label>
                   <div class="layui-input-block">
                     <input type="text" class="layui-input" autocomplete="off" id="create_time" placeholder="请选择对应的注册时间区间">
                   </div>
                 </div>
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">代理时间</label>
                   <div class="layui-input-block">
                     <input type="text" class="layui-input" autocomplete="off" id="agent_time" placeholder="请选择对应的代理时间区间">
                   </div>
                 </div>
               </div>
               <div class="layui-row layui-col-space10 layui-form-item">
                 <div class="layui-col-lg6">
                   <label class="layui-form-label">会员状态</label>
                   <div class="layui-input-block">
                     <input type="checkbox" class="layui-input" lay-skin="primary" name="status" value="1" title="正常">
                     <input type="checkbox" class="layui-input" lay-skin="primary" name="status" value="0" title="冻结">
                   </div>
                 </div>

               </div>
               <div class="layui-row">
                 <div class="layui-col-xs4">&nbsp;</div>
                 <div class="layui-col-xs4">
                   <button type="button" class="layui-btn layui-btn-normal xk-dosearch">搜索<i class="layui-icon"></i></button>
                   <button type="button" class="layui-btn layui-btn-primary close-search"><i class="layui-icon">&#x1007;</i>关闭</button>
                 </div>
                 <div class="layui-col-xs4">&nbsp;</div>
               </div>
             </div>
           </form>
         </div>
       </div>
     </div>
   </fieldset>

   <script type="text/html" id="toolbar">
     <div class="layui-btn-container">
       <button class="layui-btn layui-btn-black  layui-btn-sm" lay-event="reseve"><i class="layui-icon">&#xe63d;</i></button>
       <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="export"><i class="layui-icon">&#xe67d;</i>导出筛选后的数据</button>
       <div class="money_all"></div>
     </div>
   </script>

   <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

   <!-- <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="chanageLevel">更换等级</button> |  -->
   <script type="text/html" id="currentTableBar">
     <div class="layui-btn-group tab_custom">
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="chanageLUserSn">换绑上级</button> |
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="createLabe">贴标签</button> |
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="sendMoney">收益发放</button> |
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="checkChild">查看下级</button> |
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="getParents">查看上级</button> |
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="chanageTel">换绑手机号</button> |
       <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="chanagePass">修改密码</button> |
       {{# if(d.is_check == 1){ }}
         <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="getBankInfo">银行卡信息查看</button> |
         {{# } }}
           {{# if(d.status == 1){ }}
             <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="chanageStatus" data-status="0">会员状态</button>
             {{# }else{ }}
               <button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-sm" lay-event="chanageStatus" data-status="0">会员状态</button>
               {{# } }}
     </div>
   </script>
   <!--  <button class="layui-btn layui-btn-radius layui-btn-normal layui-btn-sm" lay-event="createAdmin">是否核销员</button> -->
   <!-- 图片 如果存在的话 -->
   <script type="text/html" id="picurlshow">
     <img src="{{d.head_pic?d.head_pic:'__COMMON__images/no_pic.png'}}" style="width:60px; height:100%" />
   </script>
 </div>
 {/block}
 {block name="myScript"}
 <!-- <style media="screen">
   .layui-table-cell {
     height: 60px;
     line-height: 60px;
   }
 </style> -->
 <script>
   layui.use(['form', 'table', 'laydate'], function() {
     var $ = layui.jquery,
       form = layui.form,
       laydate = layui.laydate,
       l_user_sn = '{$l_user_sn}',
       table = layui.table;
     laydate.render({
       elem: '#create_time',
       theme: '#1E9FFF',
       range: '~',
       type: 'datetime',
       format: 'yyyy-MM-dd HH:mm:ss'
     });
     laydate.render({
       elem: '#bind_time',
       theme: '#1E9FFF',
       range: '~',
       type: 'datetime',
       format: 'yyyy-MM-dd HH:mm:ss'
     });
     laydate.render({
       elem: '#agent_time',
       theme: '#1E9FFF',
       range: '~',
       type: 'datetime',
       format: 'yyyy-MM-dd HH:mm:ss'
     });
     table.render({
       elem: '#currentTableId',
       url: '/{:config("manage.manage_name")}/{:config("manage.version")}/User/userList',
       toolbar: '#toolbar',
       defaultToolbar: ['filter', {
         title: '搜索',
         layEvent: 'search',
         icon: 'layui-icon-search'
       }],
       where: {
         l_user_sn: l_user_sn
       },
       height: 'full-50',
       cols: [
         [{
             field: 'head_pic',
             // width: '8%',
             minWidth: '100',
             title: '头像',
             templet: "#picurlshow"
           },
           {
             field: 'user_sn',
             minWidth: '100',
             title: '会员号'
           },

           {
             field: 'user_name',
             minWidth: '150',
             title: '昵称'
           },
           {
             field: 'tel',
             minWidth: '150',
             title: '手机号'
           },
           {
             field: 'l_user_sn',
             minWidth: '100',
             title: '上级编号'
           },
           {
             field: 'l_user_name',
             minWidth: '150',
             title: '上级昵称'
           },
           {
             field: 'level_name',
             minWidth: '80',
             title: '等级'
           },
           {
             field: 'all_back_money',
             minWidth: '80',
             title: '总佣金'
           },
           {
             field: 'back_money',
             minWidth: '80',
             title: '余额'
           },
           {
             field: 'all_achievement_price',
             minWidth: '150',
             title: '团队总业绩'
           },
           {
             field: 'agent_achievement_price',
             minWidth: '150',
             title: '个人总业绩'
           },
           {
             field: 'purchases_order_price',
             minWidth: '150',
             title: '消费总金额'
           },
           {
             field: 'user_label_name',
             minWidth: '100',
             title: '标签'
           },
           {
             field: 'status_txt',
             minWidth: '100',
             title: '状态'
           },
           {
             field: 'create_time',
             minWidth: '200',
             title: '注册时间'
           },
           {
             field: 'bind_time',
             width: '200',
             title: '绑定时间'
           },
           {
             field: 'agent_time',
             minWidth: '200',
             title: '代理时间'
           },
           // {
           //   field: 'level_1_count',
           //   width: '100',
           //   title: '团队游客数'
           // },
           {
             field: 'level_2_count',
             width: '100',
             title: '团队VIP数'
           },
           {
             field: 'level_3_count',
             width: '100',
             title: '团队县代数'
           },
           {
             field: 'level_4_count',
             width: '100',
             title: '团队市代数'
           },
           {
             field: 'level_5_count',
             width: '100',
             title: '团队省代数'
           },

           {
             title: '操作',
             toolbar: '#currentTableBar',
             minWidth: '300',
             fixed: 'right',
             align: "center"
           }
         ]
       ],
       done: function (res, curr, count) {
         $(".money_all").html(res.resultData.show_count);
       },
       limits: [100, 100, 150, 200, 250, 500, 1000],
       limit: 100,
       id: 'table_ids',
       page: true,
       skin: 'line'
     });

     // 顶部操作工具
     table.on('toolbar(currentTableFilter)', function(obj) {
       var url = $(this).attr('data-url'),
         keywords = $("#keywords").val(),
         id_arr = getCheckValue();
       switch (obj.event) {
         case 'reseve':
           table.reload('table_ids');
           break;
         case 'export':
           var keywords = $("#keywords").val(),
             level = '',
             level_arr = [],
             user_label_id = '',
             user_label_id_arr = [],
             status = '',
             status_arr = [],
             l_user_sn = '{$l_user_sn}',
             now_level = '{$now_level}',
             create_time = $("#create_time").val(),
             bind_time = $("#bind_time").val(),
             agent_time = $("#agent_time").val(),
             min_purchases_order_price = $("#min_purchases_order_price").val(),
             max_purchases_order_price = $("#max_purchases_order_price").val(),
             min_back_money = $("#min_back_money").val(),
             max_back_money = $("#max_back_money").val(),
             search_user_sn = $("#search_user_sn").val(),
             has_l_user = $("#has_l_user").val();
           $("input[name=level]:checked").each(function() {
             level_arr.push($(this).val());
           });
           level = level_arr.join(',');
           $("input[name=user_label_id]:checked").each(function() {
             user_label_id_arr.push($(this).val());
           });
           user_label_id = user_label_id_arr.join(',');
           $("input[name=status]:checked").each(function() {
             status_arr.push($(this).val());
           });
           status = status_arr.join(',');
             var url = "/{:config('manage.manage_name')}/{:config('manage.version')}/User/exportUserList";
             https(url, {
               keywords: keywords,
               level: level,
               user_label_id: user_label_id,
               create_time: create_time,
               agent_time: agent_time,
               bind_time: bind_time,
               l_user_sn: l_user_sn,
               now_level: now_level,
               min_purchases_order_price: min_purchases_order_price,
               max_purchases_order_price: max_purchases_order_price,
               min_back_money: min_back_money,
               max_back_money: max_back_money,
               has_l_user: has_l_user,
               status: status,
               search_user_sn: search_user_sn,
             }, 'post', true, '正在导出会员数据').then(res => {
               if (res.result_code == 200) {
                 var html = '<h1 style="padding: 0 20px;color:red;font-size:18px;margin-bottom:15px;">如果据量大于1万条系统自动分表导出</h1>';
                 res.resultData.forEach(function(value, index) {
                   html += '<h2 style="padding: 0 20px;font-size:16px;">第' + (index + 1) + '个订单文件：<a href="' + value + '">' + '下载' + '</a></h2>';
                 })
                 layer.open({
                   type: 1,
                   skin: 'layui-layer-rim', //加上边框
                   area: ['400px', '400px'], //宽高
                   content: html
                 });
               }
             })
             break;
         case 'search':
           $("#xk-search-status").removeClass('xk-search-status');
           break;
       }
     })
     // 列表工具栏目
     table.on('tool(currentTableFilter)', function(obj) {
       var data = obj.data,
         event = obj.event,
         url = $(this).attr('data-url');
       var keywords = $("#keywords").val(),
         level = '',
         level_arr = [],
         user_label_id = '',
         user_label_id_arr = [],
         status = '',
         status_arr = [],
         l_user_sn = '{$l_user_sn}',
         now_level = '{$now_level}',
         create_time = $("#create_time").val(),
         bind_time = $("#bind_time").val(),
         agent_time = $("#agent_time").val(),
         min_purchases_order_price = $("#min_purchases_order_price").val(),
         max_purchases_order_price = $("#max_purchases_order_price").val(),
         min_back_money = $("#min_back_money").val(),
         max_back_money = $("#max_back_money").val(),
         search_user_sn = $("#search_user_sn").val(),
         has_l_user = $("#has_l_user").val();
       $("input[name=level]:checked").each(function() {
         level_arr.push($(this).val());
       });
       level = level_arr.join(',');
       $("input[name=user_label_id]:checked").each(function() {
         user_label_id_arr.push($(this).val());
       });
       user_label_id = user_label_id_arr.join(',');
       $("input[name=status]:checked").each(function() {
         status_arr.push($(this).val());
       });
       status = status_arr.join(',');
       url = url + '/user_label_id/' + data.user_label_id;
       switch (event) {
         case 'chanageLUserSn':
           var user_sn = data.user_sn,
             html =
             '<div class="layui-col-md12"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">上级会员编号：</label><div class="layui-input-block"><input type="text" id="l_user_sn" autocomplete="off" value="" class="layui-input"></div></div></div></div></div>';
           //询问框
           var showx = layer.open({
             type: 1,
             title: '换绑上级会员',
             shadeClose: false,
             shade: false,
             maxmin: false,
             area: ['800px', '400px'],
             btn: ['确认', '取消'],
             content: html,
             success: function(layero, index) {

             },
             yes: function(index, layero) {
               var l_user_sn = $("#l_user_sn").val(),
                 url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/chanageLUserSn';
               https(url, {
                 l_user_sn: l_user_sn,
                 user_sn: user_sn
               }, 'post', 1, '正在执行换绑上级').then(res => {
                 layer.msg(res.result_msg);
                 setTimeout(function() {
                   table.reload('table_ids', {
                     page: {
                       curr: 1
                     },
                     where: {
                       keywords: keywords,
                       level: level,
                       user_label_id: user_label_id,
                       create_time: create_time,
                       agent_time: agent_time,
                       bind_time: bind_time,
                       l_user_sn: l_user_sn,
                       now_level: now_level,
                       min_purchases_order_price: min_purchases_order_price,
                       max_purchases_order_price: max_purchases_order_price,
                       min_back_money: min_back_money,
                       max_back_money: max_back_money,
                       has_l_user: has_l_user,
                       status: status,
                       search_user_sn: search_user_sn,
                     }
                   }, 'data');
                   layer.close(showx);
                 }, 1500)
               })
             },
             btn2: function() {
               //alert("222");  取消时触发
             }
           });
           break;
         case 'chanageTel':
           var user_sn = data.user_sn,
             html =
             '<div class="layui-row layui-col-space15"><div class="layui-col-md12"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">会员手机号：</label><div class="layui-input-block"><input type="text" id="tel" autocomplete="off" value="" class="layui-input"></div></div></div></div></div></div>';
           //询问框
           var showx = layer.open({
             type: 1,
             title: '更换手机号',
             shadeClose: false,
             shade: false,
             maxmin: false,
             area: ['800px', '400px'],
             btn: ['确认', '取消'],
             content: html,
             success: function(layero, index) {

             },
             yes: function(index, layero) {
               var tel = $("#tel").val(),
                 url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/chanageTel';
                if(tel == ''){
                  layer.msg("请输入需要更换的手机号码");
                  return false;
                }
                if(tel.length != 11){
                  layer.msg("请输入正确的手机号码");
                  return false;
                }
               https(url, {
                 tel: tel,
                 user_sn: user_sn
               }, 'post', 1, '正在执行更换手机号').then(res => {
                 layer.msg(res.result_msg);
                 setTimeout(function() {
                   table.reload('table_ids', {
                     page: {
                       curr: 1
                     },
                     where: {
                       keywords: keywords,
                       level: level,
                       user_label_id: user_label_id,
                       create_time: create_time,
                       bind_time: bind_time,
                       agent_time: agent_time,
                       l_user_sn: l_user_sn,
                       now_level: now_level,
                       min_purchases_order_price: min_purchases_order_price,
                       max_purchases_order_price: max_purchases_order_price,
                       min_back_money: min_back_money,
                       max_back_money: max_back_money,
                       has_l_user: has_l_user,
                       status: status,
                       search_user_sn: search_user_sn,
                     }
                   }, 'data');
                   layer.close(showx);
                 }, 1500)
               })
             },
             btn2: function() {
               //alert("222");  取消时触发
             }
           });
           break;
         case 'createLabe':
           var getlabelurl = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/userLabel',
             user_sn = data.user_sn;
           // 获取会员标签
           https(getlabelurl, {
             limit: 1000
           }, 'post', false, '').then(res => {
             var html =
               '<div class="layui-col-md12 layui-form"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">请选择需要贴的标签：</label><div class="layui-input-block"><select  id="user_label_id"  lay-search> <option value="0">请选择用户标签</option>',
               list = res.resultData.list;
             list.forEach(function(item, key) {
               html += '<option value="' + item.user_label_id + '" ';
               if (item.user_label_name == data.user_label_name) {
                 html += 'selected="selected"';
               }
               html += '>' + item.user_label_name + '</option>';
             })
             html += '</select></div></div></div></div></div>';
             //询问框
             var showx = layer.open({
               type: 1,
               title: '会员标签',
               shadeClose: false,
               shade: false,
               maxmin: false,
               area: ['800px', '400px'],
               btn: ['确认', '取消'],
               content: html,
               success: function(layero, index) {
                 form.render();
               },
               yes: function(index, layero) {
                 var user_label_idx = $("#user_label_id").val(),
                   url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/chanageLabel';
                 https(url, {
                   user_label_id: user_label_idx,
                   user_sn: user_sn
                 }, 'post', 1, '正在更换会员标签').then(res => {
                   layer.msg(res.result_msg);
                   setTimeout(function() {
                     table.reload('table_ids', {
                       page: {
                         curr: 1
                       },
                       where: {
                         keywords: keywords,
                         level: level,
                         user_label_id: user_label_id,
                         create_time: create_time,
                         bind_time: bind_time,
                         agent_time: agent_time,
                         l_user_sn: l_user_sn,
                         now_level: now_level,
                         status: status,
                         min_purchases_order_price: min_purchases_order_price,
                         max_purchases_order_price: max_purchases_order_price,
                         min_back_money: min_back_money,
                         max_back_money: max_back_money,
                         has_l_user: has_l_user,
                         search_user_sn: search_user_sn,
                       }
                     }, 'data');
                     layer.close(showx);
                   }, 1500)
                 })
               },
               btn2: function() {
                 //alert("222");  取消时触发
               }
             });
           }, error => {

           })
           break;
         case 'checkChild':
           var url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/userNextList';
           url = url + '/user_sn/' + data.user_sn;
           var index = layer.open({
             title: '会员'+data.user_name+'的下级族谱',
             type: 2,
             shade: 0.2,
             maxmin: true,
             shadeClose: true,
             area: ['100%', '100%'],
             content: url,
             cancel: function() {
               // table.reload('table_ids', {
               //   where: {
               //     keywords: keywords,
               //     level: level,
               //     user_label_id: user_label_id,
               //     create_time: create_time,
               //     l_user_sn: l_user_sn,
               //     now_level: now_level,
               //   }
               // });
             }
           });
           break;
         case 'getParents':
           var url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/parentList';
           url = url + '/user_sn/' + data.user_sn;
           var index = layer.open({
             title: '会员'+data.user_name+'的族谱',
             type: 2,
             shade: 0.2,
             maxmin: true,
             shadeClose: true,
             area: ['100%', '100%'],
             content: url,
             cancel: function() {
               table.reload('table_ids', {
                 where: {
                   keywords: keywords,
                   level: level,
                   user_label_id: user_label_id,
                   create_time: create_time,
                   bind_time: bind_time,
                   agent_time: agent_time,
                   l_user_sn: l_user_sn,
                   now_level: now_level,
                   min_purchases_order_price: min_purchases_order_price,
                   max_purchases_order_price: max_purchases_order_price,
                   min_back_money: min_back_money,
                   max_back_money: max_back_money,
                   has_l_user: has_l_user,
                   status: status,
                   search_user_sn: search_user_sn,
                 }
               });
             }
           });
           break;
         case 'sendMoney':
           var user_sn = data.user_sn,
             html =
             '<div class="layui-col-md12"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">发放收益：</label><div class="layui-input-block"><input type="text" id="send_money" autocomplete="off" value="" class="layui-input"></div></div></div><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">发放备注：</label><div class="layui-input-block"><input type="text" id="send_content" autocomplete="off" value="" class="layui-input"></div></div></div></div></div>';
           //询问框
           var showx = layer.open({
             type: 1,
             title: '定点发放收益',
             shadeClose: false,
             shade: false,
             maxmin: false,
             area: ['800px', '400px'],
             btn: ['确认', '取消'],
             content: html,
             success: function(layero, index) {

             },
             yes: function(index, layero) {
               var send_money = $("#send_money").val(),
                 send_content = $("#send_content").val(),
                 url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/sendMoney';
               https(url, {
                 money: send_money,
                 content: send_content,
                 user_sn: user_sn
               }, 'post', 1, '正在发放收益').then(res => {
                 layer.msg(res.result_msg);
                 setTimeout(function() {
                   table.reload('table_ids', {
                     page: {
                       curr: 1
                     },
                     where: {
                       keywords: keywords,
                       level: level,
                       user_label_id: user_label_id,
                       create_time: create_time,
                       bind_time: bind_time,
                       agent_time: agent_time,
                       l_user_sn: l_user_sn,
                       now_level: now_level,
                       min_purchases_order_price: min_purchases_order_price,
                       max_purchases_order_price: max_purchases_order_price,
                       min_back_money: min_back_money,
                       max_back_money: max_back_money,
                       has_l_user: has_l_user,
                       status: status,
                       search_user_sn: search_user_sn,
                     }
                   }, 'data');
                   layer.close(showx);
                 }, 1500)
               })
             },
             btn2: function() {
               //alert("222");  取消时触发
             }
           });
           break;
         case 'chanagePass':
           var user_sn = data.user_sn,
             html =
             '<div class="layui-col-md12"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">请输入密码：</label><div class="layui-input-block"><input type="text" id="pass" autocomplete="off" value="" class="layui-input"></div></div></div><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">请输入确认密码：</label><div class="layui-input-block"><input type="text" id="pass1" autocomplete="off" value="" class="layui-input"></div></div></div></div></div>';
           //询问框
           var showx = layer.open({
             type: 1,
             title: '修改登录密码',
             shadeClose: false,
             shade: false,
             maxmin: false,
             area: ['800px', '400px'],
             btn: ['确认', '取消'],
             content: html,
             success: function(layero, index) {

             },
             yes: function(index, layero) {
               var pass = $("#pass").val(),
                 pass1 = $("#pass1").val(),
                 url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/chanagePass';
               https(url, {
                 pass: pass,
                 pass1: pass1,
                 user_sn: user_sn
               }, 'post', 1, '正在修改登录密码').then(res => {
                 layer.msg(res.result_msg);
                 setTimeout(function() {
                   table.reload('table_ids', {
                     page: {
                       curr: 1
                     },
                     where: {
                       keywords: keywords,
                       level: level,
                       user_label_id: user_label_id,
                       create_time: create_time,
                       bind_time: bind_time,
                       agent_time: agent_time,
                       l_user_sn: l_user_sn,
                       now_level: now_level,
                       status: status,
                       min_purchases_order_price: min_purchases_order_price,
                       max_purchases_order_price: max_purchases_order_price,
                       min_back_money: min_back_money,
                       max_back_money: max_back_money,
                       has_l_user: has_l_user,
                       search_user_sn: search_user_sn,
                     }
                   }, 'data');
                   layer.close(showx);
                 }, 1500)
               })
             },
             btn2: function() {
               //alert("222");  取消时触发
             }
           });
           break;
         case 'chanageLevel':
           var getlabelurl = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/userLevel',
             user_sn = data.user_sn;
           // 获取会员标签
           https(getlabelurl, {
             limit: 1000
           }, 'post', false, '').then(res => {
             var html =
               '<div class="layui-col-md12 layui-form"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">请选择需要更换的等级：</label><div class="layui-input-block"><select  id="user_level"  lay-search> <option value="0">请选择用户等级</option>',
               list = res.resultData.list;
             list.forEach(function(item, key) {
               html += '<option value="' + item.level + '" ';
               if (item.level_name == data.level_name) {
                 html += 'selected="selected"';
               }
               html += '>' + item.level_name + '</option>';
             })
             html += '</select></div></div></div></div></div>';
             //询问框
             var showx = layer.open({
               type: 1,
               title: '会员标签',
               shadeClose: false,
               shade: false,
               maxmin: false,
               area: ['800px', '400px'],
               btn: ['确认', '取消'],
               content: html,
               success: function(layero, index) {
                 form.render();
               },
               yes: function(index, layero) {
                 var user_level = $("#user_level").val(),
                   old_level = data.level,
                   url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/chanageLevel';
                 https(url, {
                   user_level: user_level,
                   old_level: old_level,
                   user_sn: user_sn
                 }, 'post', 1, '正在更换会员等级').then(res => {
                   layer.msg(res.result_msg);
                   setTimeout(function() {
                     table.reload('table_ids', {
                       page: {
                         curr: 1
                       },
                       where: {
                         keywords: keywords,
                         level: level,
                         user_label_id: user_label_id,
                         create_time: create_time,
                         bind_time: bind_time,
                         agent_time: agent_time,
                         l_user_sn: l_user_sn,
                         now_level: now_level,
                         min_purchases_order_price: min_purchases_order_price,
                         max_purchases_order_price: max_purchases_order_price,
                         min_back_money: min_back_money,
                         max_back_money: max_back_money,
                         has_l_user: has_l_user,
                         status: status,
                         search_user_sn: search_user_sn,
                       }
                     }, 'data');
                     layer.close(showx);
                   }, 1500)
                 })
               },
               btn2: function() {
                 //alert("222");  取消时触发
               }
             });
           }, error => {

           })
           break;
         case 'chanageStatus':
           var createadminurl = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/chanageStatus';
           layer.msg('请选择当前会员状态操作', {
             time: 0,
             btn: ['冻结', '解冻', '取消'],
             yes: function(index) {
               layer.close(index);
               https(createadminurl, {
                 user_sn: data.user_sn,
                 status: 0
               }, 'post', true, '正在冻结会员').then(res => {
                 if (res.result_code == 200) {
                   table.reload('table_ids', {
                     where: {
                       keywords: keywords,
                       level: level,
                       user_label_id: user_label_id,
                       create_time: create_time,
                       bind_time: bind_time,
                       agent_time: agent_time,
                       l_user_sn: l_user_sn,
                       now_level: now_level,
                       min_purchases_order_price: min_purchases_order_price,
                       max_purchases_order_price: max_purchases_order_price,
                       min_back_money: min_back_money,
                       max_back_money: max_back_money,
                       has_l_user: has_l_user,
                       status: status,
                       search_user_sn: search_user_sn,
                     }
                   });
                 }
               })
             },
             btn2: function(index) {
               layer.close(index);
               https(createadminurl, {
                 user_sn: data.user_sn,
                 status: 1
               }, 'post', true, '正在解冻会员').then(res => {
                 if (res.result_code == 200) {
                   table.reload('table_ids', {
                     where: {
                       keywords: keywords,
                       level: level,
                       user_label_id: user_label_id,
                       create_time: create_time,
                       bind_time: bind_time,
                       agent_time: agent_time,
                       l_user_sn: l_user_sn,
                       now_level: now_level,
                       min_purchases_order_price: min_purchases_order_price,
                       max_purchases_order_price: max_purchases_order_price,
                       min_back_money: min_back_money,
                       max_back_money: max_back_money,
                       has_l_user: has_l_user,
                       status: status,
                       search_user_sn: search_user_sn,
                     }
                   });
                 }
               })
             },
             btn3: function(index) {
               layer.close(index);
             }
           });
           break;
         case 'getBankInfo':
           var card_num = data.card_num,
             url = '/{:config("manage.manage_name")}/{:config("manage.version")}/User/getBankInfo';
           https(url, {
             card_num: card_num
           }, 'post', 0, '查询银行卡').then(res => {
             if (res.resultData) {
              var html =
              '<div class="layui-col-md12"><div class="layui-card-body layui-form layui-form-pane"><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">姓名</label><div class="layui-input-block"><input type="text" autocomplete="off" value="' +
              res.resultData.name +
              '" disabled class="layui-input"></div></div></div><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">电话</label><div class="layui-input-block"><input type="text" autocomplete="off" value="' +
              res.resultData.phone +
              '" disabled class="layui-input"></div></div></div><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">身份证号码</label><div class="layui-input-block"><input type="text" disabled autocomplete="off" value="' +
              res.resultData.idCard +
              '" class="layui-input"></div></div></div><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">开户行</label><div class="layui-input-block"><input type="text" disabled autocomplete="off" value="' +
              res.resultData.depositBank +
              '" class="layui-input"></div></div></div><div class="layui-row layui-col-space12 layui-form-item"><div class="layui-col-lg8"><label class="layui-form-label">银行卡号</label><div class="layui-input-block"><input type="text" disabled autocomplete="off" value="' +
              res.resultData.account + '" class="layui-input"></div></div></div></div></div>';
               var index = layer.open({
                 type: 1,
                 title: '银行卡信息',
                 shadeClose: true,
                 shade: 0.2,
                 maxmin: true,
                 area: ['800px', '400px'],
                 content: html,
                 success: function(layero, index) {},
                 yes: function(index, layero) {},
                 btn2: function() {

                 }
               });
             } else {
               layer.msg(res.result_msg)
             }
           })
           break;
       }
     })
     // 执行搜索
     $(".xk-dosearch").click(function() {
       var keywords = $("#keywords").val(),
         level = '',
         level_arr = [],
         user_label_id = '',
         user_label_id_arr = [],
         status = '',
         status_arr = [],
         l_user_sn = '{$l_user_sn}',
         now_level = '{$now_level}',
         create_time = $("#create_time").val(),
         bind_time = $("#bind_time").val(),
         agent_time = $("#agent_time").val(),
         min_purchases_order_price = $("#min_purchases_order_price").val(),
         max_purchases_order_price = $("#max_purchases_order_price").val(),
         min_back_money = $("#min_back_money").val(),
         max_back_money = $("#max_back_money").val(),
         search_user_sn = $("#search_user_sn").val(),
         has_l_user = $("#has_l_user").val();
       $("input[name=level]:checked").each(function() {
         level_arr.push($(this).val());
       });
       level = level_arr.join(',');
       $("input[name=user_label_id]:checked").each(function() {
         user_label_id_arr.push($(this).val());
       });

       user_label_id = user_label_id_arr.join(',');
       $("input[name=status]:checked").each(function() {
         status_arr.push($(this).val());
       });
       status = status_arr.join(',');

       table.reload('table_ids', {
         page: {
           curr: 1
         },
         where: {
           keywords: keywords,
           level: level,
           user_label_id: user_label_id,
           create_time: create_time,
           bind_time: bind_time,
           agent_time: agent_time,
           l_user_sn: l_user_sn,
           now_level: now_level,
           min_purchases_order_price: min_purchases_order_price,
           max_purchases_order_price: max_purchases_order_price,
           min_back_money: min_back_money,
           max_back_money: max_back_money,
           has_l_user: has_l_user,
           status: status,
           search_user_sn: search_user_sn,
         }
       }, 'data');
     })
     // 获取选中项
     function getCheckValue() {
       var id_arr = [],
         id_str = '';
       var checkStatus = table.checkStatus('table_ids'),
         data = checkStatus.data;
       data.map(function(d) {
         id_arr.push(d.user_label_id);
       })
       id_str = id_arr.join(',');
       return id_str;
     }
   });
 </script>
 {/block}
